package com.voicechat.firstmet.imcontrol;

import android.util.Log;

import com.tencent.TIMManager;
import com.tencent.TIMUserStatusListener;
import com.voicechat.firstmet.App;
import com.voicechat.firstmet.utils.Utils;

/**
 * @ProjectName: FirstMet
 * @Package: com.voicechat.firstmet.imcontrol
 * @ClassName: LoginStateListener
 * @Description: 用户状态变更类
 * @Author: ljp
 * @CreateDate: 2018/11/29 19:39
 * @Version: 1.0
 */
public class LoginStateListener implements TIMUserStatusListener {

    private volatile static LoginStateListener instance;
    private static String TAG = "LoginStateListener";

    private LoginStateListener(){
        //注册用户状态变更提醒
        TIMManager.getInstance().setUserStatusListener(this);
        Log.i(TAG, "LoginStateListener: ---------------");
    }

    public static LoginStateListener getInstance(){
        if (instance == null) {
            synchronized (LoginStateListener.class) {
                if (instance == null) {
                    instance = new LoginStateListener();
                    Log.i(TAG, "getInstance: ---------------");
                }
            }
        }
        return instance;
    }
    //被踢下线回调
    @Override
    public void onForceOffline() {
        Log.i(TAG, "onForceOffline: -----被踢下线回调----");
        Utils.setToken(App.getContext());

    }
    /**
     * 票据过期时回调
     */
    @Override
    public void onUserSigExpired() {
        Log.i(TAG, "onUserSigExpired: -----票据过期时回调----");
    }
}
